package com.learn.my;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.TimeUnit;

public class Test0002 {


    public static void main(String[] args) throws InterruptedException {
        //阻塞队列，最多支持队列总数 4，由自己设置
        BlockingQueue<String> stringConcurrentLinkedQueue=new ArrayBlockingQueue<String>(3);

        stringConcurrentLinkedQueue.offer("张三");//添加非阻塞队列
        stringConcurrentLinkedQueue.offer("李四",3, TimeUnit.SECONDS);//添加阻塞队列

        //获取队列
        System.out.println(stringConcurrentLinkedQueue.poll());
        System.out.println(stringConcurrentLinkedQueue.poll());
        System.out.println(stringConcurrentLinkedQueue.poll(3,TimeUnit.SECONDS));
    }
}
